var currentCarId;//当前监控的车辆ID
var currentCarType;//当前车辆类型，1为传统车辆，2为新能源车辆，3为混合动力，4为双路BMS车型，默认为1；

var $traditionEnergeContainer = $('#tradition-energe'),//传统车监控显示区域
    $newEnergeContainer = $('#new-energe'),//新能源车辆监控显示区域
    $mixinEnergeContainer = $('#mixin-energe'),//混合动力显示区域
    $bmsContainer = $('#bms');//双路BMS车型显示区域

var $monitor = $('#monitor');

var bus, map;

var defultWhiteStyle = true;

var checkSelCar;

function updateMeterValue(obj,val){
    obj.highcharts().series[0].points[0].update(val);
}

//根据车辆类型进行仪表盘的切换
function meterSwitch(typeDetail) {
    var target = $traditionEnergeContainer;
    currentCarType = 1;
    if (typeDetail == 'CAT00004') {//新能源
        currentCarType = 2;
        target = $newEnergeContainer;
        newEnergeConInit();
    } else if (typeDetail == 'CAT00003') {//混合动力
        currentCarType = 3;
        target = $mixinEnergeContainer;
        mixinEnergeConInit();
    } else if (typeDetail == 'CAT00007') {
        currentCarType = 4;
        target = $bmsContainer;
        bmsConInit();
    }

    if (target.is(':hidden')) {
        $traditionEnergeContainer.hide();
        $newEnergeContainer.hide();
        $mixinEnergeContainer.hide();
        $bmsContainer.hide();
        (target.show())[defultWhiteStyle ? "removeClass" : "addClass"]('black');
    }
}

var $carLock = $('#carLock');//锁车按钮
//根据车辆锁车状态设置锁车按钮的文本及样式
function setCarLockLabelAndStyle(lockSt) {
    if (lockSt == 1) {
        $carLock.addClass('meter-unlock-car').text('车辆已锁定(点击解锁)');
    } else {
        $carLock.removeClass('meter-unlock-car').text('车辆未锁定(点击锁定)');
    }
}

//传统车辆显示区域初始化
function traditionConInit() {
    // 车速
    $('#container-speed').highcharts(getGaugeOptions({
        min: 0,
        max: 180,
        center: ['50%', '65%'],
        size: '125%',
        startAngle: -120,
        endAngle: 120,
        stops: [[0.2, '#2dbbef'],
            [0.4, '#34E259'],
            [0.6, '#FCD821'],
            [0.9, '#FB3D3D']
        ]
    }));
    // 转速
    $('#container-rpm').highcharts(getGaugeOptions({
        min: 0,
        max: 120,
        center: ['50%', '65%'],
        size: '125%',
        startAngle: -120,
        endAngle: 120,
        stops: [[0.2, '#2dbbef'],
            [0.4, '#34E259'],
            [0.6, '#FCD821'],
            [0.9, '#FB3D3D']
        ]
    }));

    //前气压
    $('#frontAirPressureChart').highcharts(getGaugeOptions({
        min: 0,
        max: 1,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: 180,
        endAngle: 330,
        stops: [[0.1, '#34E259'], // red
            [0.4, '#FCD821'], // yellow
            [0.7, '#55BF3B'],// green
            [0.9, '#55BF3B']
        ]
    }));

    //后气压
    var $backAirPressureChart = $('#backAirPressureChart');
    $backAirPressureChart.highcharts(getGaugeOptions({
        min: 0,
        max: 1,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: 180,
        endAngle: 30,
        stops: [[0.1, '#34E259'], // red
            [0.4, '#FCD821'], // yellow
            [0.7, '#55BF3B'],// green
            [0.9, '#55BF3B']
        ]
    }));
    $('path', $backAirPressureChart).eq(0).hide();

    $('shape', $backAirPressureChart).eq(1).hide();
}

//新能源车辆显示区域初始化
function newEnergeConInit() {
    if (newEnergeConInit.init) {
        return;
    }
    newEnergeConInit.init = true;

    // 车速
    $('#container-speed-2').highcharts(getGaugeOptions({
        min: 0,
        max: 180,
        center: ['50%', '65%'],
        size: '125%',
        startAngle: -120,
        endAngle: 120,
        stops: [[0.2, '#2dbbef'],
            [0.4, '#34E259'],
            [0.6, '#FCD821'],
            [0.9, '#FB3D3D']
        ]
    }));
    // 转速
    $('#container-rpm-2').highcharts(getGaugeOptions({
        min: 0,
        max: 120,
        center: ['50%', '65%'],
        size: '125%',
        startAngle: -120,
        endAngle: 120,
        stops: [[0.2, '#2dbbef'],
            [0.4, '#34E259'],
            [0.6, '#FCD821'],
            [0.9, '#FB3D3D']
        ]
    }));

    //动力电池电压
    $('#battery-voltage-chart-2').highcharts(getGaugeOptions({
        min: 0,
        max: 800,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: -50,
        endAngle: 50,
        stops: [[400, '#55BF3B']]
    }));

    //动力电池电流
    $('#battery-circuit-chart-2').highcharts(getGaugeOptions({
        min: -600,
        max: 600,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: -50,
        endAngle: 50,
        stops: [[400, '#55BF3B']]
    }));

    //前气压
    $('#frontAirPressureChart-2').highcharts(getGaugeOptions({
        min: 0,
        max: 1,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: -50,
        endAngle: 50,
        stops: [
            [0.1, '#34E259'],
            [0.4, '#FCD821'],
            [0.7, '#55BF3B'],
            [0.9, '#55BF3B']
        ]
    }));

    //后气压
    $('#backAirPressureChart-2').highcharts(getGaugeOptions({
        min: 0,
        max: 1,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: -50,
        endAngle: 50,
        stops: [
            [0.1, '#34E259'],
            [0.4, '#FCD821'],
            [0.7, '#55BF3B'],
            [0.9, '#55BF3B']
        ]
    }));
}

//混合动力车辆显示区域初始化
function mixinEnergeConInit() {
    if (mixinEnergeConInit.init) {
        return;
    }
    mixinEnergeConInit.init = true;
    // 车速
    $('#container-speed-3').highcharts(getGaugeOptions({
        min: 0,
        max: 180,
        center: ['50%', '65%'],
        size: '125%',
        startAngle: -120,
        endAngle: 120,
        stops: [[0.2, '#2dbbef'],
            [0.4, '#34E259'],
            [0.6, '#FCD821'],
            [0.9, '#FB3D3D']
        ]
    }));
    // 转速
    $('#container-rpm-3').highcharts(getGaugeOptions({
        min: 0,
        max: 120,
        center: ['50%', '65%'],
        size: '125%',
        startAngle: -120,
        endAngle: 120,
        stops: [[0.2, '#2dbbef'],
            [0.4, '#34E259'],
            [0.6, '#FCD821'],
            [0.9, '#FB3D3D']
        ]
    }));

    //动力电池电压
    $('#battery-voltage-chart-3').highcharts(getGaugeOptions({
        min: 0,
        max: 800,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: -50,
        endAngle: 50,
        stops: [[400, '#55BF3B']]
    }));

    //动力电池电流
    $('#battery-circuit-chart-3').highcharts(getGaugeOptions({
        min: -600,
        max: 600,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: -50,
        endAngle: 50,
        stops: [[400, '#55BF3B']]
    }));

    //前气压
    $('#frontAirPressureChart-3').highcharts(getGaugeOptions({
        min: 0,
        max: 1,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: -50,
        endAngle: 50,
        stops: [
            [0.1, '#34E259'],
            [0.4, '#FCD821'],
            [0.7, '#55BF3B'],
            [0.9, '#55BF3B']
        ]
    }));

    //后气压
    $('#backAirPressureChart-3').highcharts(getGaugeOptions({
        min: 0,
        max: 1,
        center: ['50%', '50%'],
        size: '100%',
        startAngle: -50,
        endAngle: 50,
        stops: [
            [0.1, '#34E259'],
            [0.4, '#FCD821'],
            [0.7, '#55BF3B'],
            [0.9, '#55BF3B']
        ]
    }));
}

//双路BMS车辆显示区域初始化
function bmsConInit() {
    if (bmsConInit.init) {
        return;
    }
    bmsConInit.init = true;
    // 车速
    $('.speed-meter', $bmsContainer).highcharts(getGaugeOptions({
        min: 0,
        max: 180,
        center: ['50%', '65%'],
        size: '125%',
        startAngle: -120,
        endAngle: 120,
        stops: [[0.2, '#2dbbef'],
            [0.4, '#34E259'],
            [0.6, '#FCD821'],
            [0.9, '#FB3D3D']
        ]
    }));
    // 转速
    $('.rpm-meter', $bmsContainer).highcharts(getGaugeOptions({
        min: 0,
        max: 40,
        center: ['50%', '65%'],
        size: '125%',
        startAngle: -120,
        endAngle: 120,
        stops: [[0.2, '#2dbbef'],
            [0.4, '#34E259'],
            [0.6, '#FCD821'],
            [0.9, '#FB3D3D']
        ]
    }));
    //动力电池电压、电流
    $('.battery-voltage-meter1,.battery-voltage-meter2', $bmsContainer).each(function () {
        $(this).highcharts(getGaugeOptions({
            min: 0,
            max: 800,
            center: ['50%', '50%'],
            size: '100%',
            startAngle: -50,
            endAngle: 50,
            stops: [[600, '#55BF3B']]
        }));
    });

    $('.battery-circuit-meter1,.battery-circuit-meter2', $bmsContainer).each(function () {
        $(this).highcharts(getGaugeOptions({
            min: -600,
            max: 600,
            center: ['50%', '50%'],
            size: '100%',
            startAngle: -50,
            endAngle: 50,
            stops: [[600, '#55BF3B']]
        }));
    });
}

//绑定事件
function bindEvents() {

    //风格切换
    $('#styleChangeBtn').on('click', function () {
        $('.generous-meter-wrap:visible,#detail-info').toggleClass('black');
        defultWhiteStyle = !defultWhiteStyle;
    });

    $carLock.on('click', function () {
        //TODO 锁车功能待完善
        return;
        if (!currentCarId) {
            return;
        }
        var lockSt = 1;
        var title = '锁定';
        if ($(this).hasClass('meter-unlock-car')) {
            lockSt = 0;
            title = '解锁';
        }
        $.messager.confirm(title + '确认', '确定要' + title + '车辆吗？', function (r) {
            if (r) {
                $monitor.monitor('stop');
                $.ajaxExt({
                    url: '/baseCarInfo/uptCarLockStatus.htm',
                    params: {
                        carId: currentCarId,
                        canId: 7,
                        ac: lockSt
                    },
                    success: function (data) {
                        var msgJson = $.parseJSON(data);
                        if (msgJson.head.state_code == 1) {//失败
                            $.messager.alert('失败', msgJson.head.state_desc);
                            return;
                        }
                        setCarLockLabelAndStyle(lockSt);
                        $monitor.monitor('start');
                        window.parent.$('#leftTreeArea').leftOrg('setCarLockSt', currentCarId, lockSt);
                    }
                });
            }
        });
    });

    var $iCenter = $('#iCenter');
    var $monitorWrap = $('.monitor-wrap');
    $monitorWrap.draggable({
        containment: "document"
    }).resizable({
        minHeight: 156,
        minWidth: 254
    }).find('>a').on('click', function () {
        if ($(this).hasClass('shrink')) {
            $iCenter.parent().removeAttr('style');
        } else {
            $iCenter.parent().css({
                top: 0,
                left: 0,
                width: $(window).width() - 30,
                height: $(window).height() - 64
            });
        }
        $(this).toggleClass('shrink');
    });
}

/**
 * 设置指示灯样式
 * @param selector {string|jQuery} 指示灯选择器
 * @param val {string|number} 指示灯具体的值
 * @param charAtIndex {null|number} 指示灯值可能包括很多位数，需要取具体某位的值
 */
function setLightStyle(selector, val, charAtIndex) {
    if (typeof  selector === 'string') {
        selector = $(selector);
    }
    if (!val || (!charAtIndex || val.charAt(val.length - charAtIndex) % 2 === 0)) {
        selector.removeClass('active');
    } else {
        selector.addClass('active');
    }
}

/**
 * 设置GPS信号样式
 * @param selector {string|jQuery} 指示灯选择器
 * @param val {string|number} 指示灯具体的值
 * @param charAtIndex {null|number} 指示灯值可能包括很多位数，需要取具体某位的值
 */
function setGpsSignalStyle(selector, val, charAtIndex){
    if (typeof  selector === 'string') {
        selector = $(selector);
    }
    if (!val || (!charAtIndex || val.charAt(val.length - charAtIndex) % 2 === 0)) {
        selector.removeClass('online').attr('title','GPS离线');
    } else {
        selector.addClass('online').attr('title','GPS在线');
    }
}

function loadData(data) {
    //经纬度
    if (data.loLgt && data.loLtt) {
        if (bus) {
            bus.clear();
        }
        if (map.map.getZoom() < 10) {
            map.setMapLevel(14);
        }
        bus = new Bus(map, '', data.loLgt, data.loLtt, data.direction);
        //bus.setDirection(data.direction);
        bus.show();
        map.mapMoveTo(data.loLgt, data.loLtt);
    }
    else{
        if (bus) {
            bus.clear();
        }
        map.setMapCenterAndLevel(107.49023438, 36.24427318, 2);
    }

    var preStnName = '', nextStnName = '';
    //上下站点名称
    if (data.preNextStnName) {
        preStnName = data.preNextStnName.split('-')[0];
        nextStnName = data.preNextStnName.split('-')[1];
        if (typeof(nextStnName) == "undefined") {
            nextStnName = preStnName;
        }
    }
    $('#prev-station').empty().
        append('<i class="icon-station"></i>' + preStnName)
        .next().next().empty().append('<i class="icon-station"></i>' + nextStnName);

    if (currentCarType == 1) {//新能源车辆调用loadNewEngineDataView
        loadTradition(data);
    } else if (currentCarType == 2) {//新能源车辆调用loadNewEngineDataView
        loadNewEngineDataView(data);
    } else if (currentCarType == 3) {//混合动力
        loadMixinEngineDataView(data);
    } else if (currentCarType == 4) {
        loadBMSDataView(data);
    }
}

//加载传统动力数据
function loadTradition(data) {
    //车速
    var speedChart = $('#container-speed').highcharts(),
        speedPoint = speedChart.series[0].points[0];

    var speedVal = data.speedOfAMotorVehicle || 0;
    speedPoint.update(speedVal);
    $('#speed-text').empty().append('<p style="width:100px;text-align:right;display:inline-block;">' +
    speedVal + '</p><span> <i>/</i> 限' + (data.limitSpeed || 55) + '</span>');


    //转速
    var rpmChart = $('#container-rpm').highcharts(),
        rmpPoint = rpmChart.series[0].points[0];

    var rpmVal = (data.rotateSpeed || 0) / 100;
    rmpPoint.update(rpmVal);
    $('#rpm-text').text((rpmVal * 100).toFixed(0));

    //油量
    var $oilNum = $('#oil-num'),
        oilNum = data.oilMass || 0;
    $oilNum.empty().append(oilNum + '<i>%</i>');
    $oilNum.parent().siblings('.num-area').animate({height: oilNum + '%'}, 800, 'easeOutBounce');


    //水温
    var $waterTemp = $('#water-temp'),
        waterTemp = data.waterTemperature || 0;
    $('.num-area', $waterTemp).animate({height: waterTemp > 100 ? '100' : waterTemp + '%'}, 800, 'easeOutBounce');
    $('span', $waterTemp).empty().append(waterTemp + '<i>℃</i>');

    //前气压
    var frontAirPressure = parseFloat(((data.frontAirPressure || 0) ).toFixed(2));
    var frontAirChart = $('#frontAirPressureChart').highcharts(),
        frontAirPoint = frontAirChart.series[0].points[0];
    frontAirPoint.update(frontAirPressure);
    $('#frontAir-p').text(frontAirPressure);

    //后气压
    var backAirPressure = parseFloat(((data.backAirPressure || 0) ).toFixed(2));
    var backAirChart = $('#backAirPressureChart').highcharts(),
        backAirPoint = backAirChart.series[0].points[0];
    backAirPoint.update(backAirPressure);
    $('#backAir-p').text(backAirPressure);

    //档位
    var gear = data.gearsStatus || 0,
        $gear = $('#gear');
    if (data.gearsStatus == 0) {
        $gear.text('N');
    } else if (data.gearsStatus == -1) {
        $gear.text('R');
    } else if (data.gearsStatus == 13) {
        $gear.text('P');
    } else if (data.gearsStatus == 1) {
        $gear.text('D');
    }


    //机油压力
    var engineOilPressure = (data.engineOilPressure || 0).toFixed(2);
    $('#engineOilPressure-val').empty().append(engineOilPressure + '<span>mpa</span>');
    $('#engineOilPressure-div').animate({height: (engineOilPressure * 100) + '%'}, 800, 'easeOutBounce');

    //电池电压
    var batteryVoltage = (data.batteryElectricQuantity || 0).toFixed(1);
    $('#batteryVoltage-val').empty().append(batteryVoltage + '<span>v</span>');
    $('#batteryVoltage-div').animate({height: batteryVoltage > 36 ? 100 : (batteryVoltage * 100 / 36) + '%'}, 800, 'easeOutBounce');

    //瞬时能耗
    var instantFuelConsumption = (data.instantFuelConsumption || 0);
    $('#instantFuelConsumption').empty().append(instantFuelConsumption.toFixed(1));

    //尿素
    var ureaLevel = (data.ureaLevel || 0).toFixed(2);
    $('#ureaLevel').empty().append(ureaLevel + ' <span>%</span>');

    //总里程
    var totalMileage = (data.totalMile || 0).toFixed(2);
    $('#totalMileage').empty().append(totalMileage + ' <i>km</i>');

    //总能耗
    var totalFuelCsut = (data.totalFuelConsumption || 0);
    $('#totalFuelCsut').empty().append(totalFuelCsut.toFixed(2) + ' <i>L</i>');

    var lightFlag = data.traditionalIndicatorLightSwitch || '';

    //左转向灯
    setLightStyle('#turnLeft', lightFlag, 1);

    // 前雾灯
    setLightStyle('#frontFogLight', lightFlag, 5);

    // 后雾灯
    setLightStyle('#backFogLight', lightFlag, 6);

    //近光灯
    setLightStyle('#nearLight', lightFlag, 4);

    //远光灯
    setLightStyle('#farLight', lightFlag, 3);

    //ABS
    setLightStyle('#abs', lightFlag, 28);

    //手刹灯
    setLightStyle('#handBrakeLight', lightFlag, 7);
    //脚刹指示灯
    setLightStyle('#brakeLight', lightFlag, 11);

    //右转向灯
    setLightStyle('#turnRight', lightFlag, 2);

    //前门
    setLightStyle($('.icon-flag18', $traditionEnergeContainer), lightFlag, 12);

    //中门
    setLightStyle($('.icon-flag19', $traditionEnergeContainer), lightFlag, 13);

    //后仓门
    setLightStyle($('.icon-flag16', $traditionEnergeContainer), lightFlag, 14);

    //LED
    setLightStyle($('.icon-flag24', $traditionEnergeContainer), lightFlag, 26);

    //Gps信号
    setGpsSignalStyle('.gps-icon1',lightFlag,30);
}

//加载新能源数据
function loadNewEngineDataView(data) {
    //指示灯、报警灯
    //此处写法参见传统车的监控
    var lightFlag = data.traditionalIndicatorLightSwitch || '';
    var lightFlagLength = lightFlag.length;
    var newEnergyIndicatorLightSwitch = data.newEnergyIndicatorLightSwitch || '';
    var newEnergyIndicatorLightSwitchLength = newEnergyIndicatorLightSwitch.length;
    //右转向灯
    setLightStyle('#icon-flag9', lightFlag, 2);

    //左转向灯
    setLightStyle('#icon-flag1', lightFlag, 1);

    // 后雾灯
    setLightStyle('#icon-flag3', lightFlag, 6);

    // 前雾灯
    setLightStyle('#icon-flag2', lightFlag, 5);

    //近光灯
    setLightStyle('#icon-flag4', lightFlag, 4);

    //远光灯
    setLightStyle('#icon-flag5', lightFlag, 3);

    //ABS
    setLightStyle('#icon-flag6', lightFlag, 28);

    //驻车制动器
    setLightStyle('#icon-flag7', lightFlag, 7);

    //脚刹指示灯
    setLightStyle('#icon-flag10', lightFlag, 11);

    //电池统电指示灯
    setLightStyle('#icon-flag15', newEnergyIndicatorLightSwitch, 5);

    //安全带指示灯
    setLightStyle('#icon-flag11', lightFlag, 30);
    // var $iconflag11 = $("#icon-flag11");
    // if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
    //     $iconflag11.removeClass('active');
    // } else {
    //     $iconflag11.addClass('active');
    // }
    //后仓门开信号
    setLightStyle('#icon-flag16', lightFlag, 14);

    //位置灯指示
    setLightStyle('#icon-flag17', lightFlag, 8);

    //前车门
    setLightStyle('#icon-flag18', lightFlag, 12);

    //中门
    setLightStyle('#icon-flag19', lightFlag, 13);

    //严重故障
    setLightStyle('#icon-flag2-1', lightFlag, 10);

    //蓄电池指示灯
    var $iconflag22 = $("#icon-flag2-2");
    if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
        $iconflag22.removeClass('active');
    } else {
        // $iconflag22.addClass('active');
    }
    //充电连接故障
    var $iconflag23 = $("#icon-flag2-3");
    if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
        $iconflag23.removeClass('active');
    } else {
        //$iconflag23.addClass('active');
    }
    //胎压报警
    setLightStyle('#icon-flag2-4', lightFlag, 24);

    //电机及按制器过热
    setLightStyle('#icon-flag2-5', newEnergyIndicatorLightSwitch, 8);

    //电机超速报警
    var $iconflag26 = $("#icon-flag2-6");
    if (!newEnergyIndicatorLightSwitch || newEnergyIndicatorLightSwitch.charAt(lightFlagLength - 1) % 2 === 0) {
        $iconflag26.removeClass('active');
    } else {
        // $iconflag26.addClass('active');
    }
    //整车控制器故障
    var $iconflag27 = $("#icon-flag2-7");
    if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
        $iconflag27.removeClass('active');
    } else {
        //   $iconflag27.addClass('active');
    }
    //Gps信号
    setGpsSignalStyle('.gps-icon1',lightFlag,30);

    //下车铃指示灯
    setLightStyle('#icon-flag2-8', lightFlag, 18);

    //干燥器
    var $iconflag29 = $("#icon-flag2-9");
    if (!newEnergyIndicatorLightSwitchLength || newEnergyIndicatorLightSwitch.charAt(newEnergyIndicatorLightSwitchLength - 1) % 2 === 0) {
        $iconflag29.removeClass('active');
    } else if (newEnergyIndicatorLightSwitch.charAt(newEnergyIndicatorLightSwitchLength - 1) == 3) {
        $iconflag29.removeClass('active');
    } else {
        $iconflag29.addClass('active');
    }
    //左蹄片报警
    setLightStyle('#icon-flag2-10', lightFlag, 19);

    //右蹄片报警
    setLightStyle('#icon-flag2-11', lightFlag, 20);

    //ASR故障
    setLightStyle('#icon-flag2-12', lightFlag, 29);

    //制动器故障
    var $iconflag213 = $("#icon-flag2-13");
    if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 29) % 2 === 0) {
        $iconflag213.removeClass('active');
    } else {
//            $iconflag213.addClass('active');
    }
    //动力电池故障
    setLightStyle('#icon-flag2-14', newEnergyIndicatorLightSwitch, 4);

    //系统故障
    setLightStyle('#icon-flag2-15', newEnergyIndicatorLightSwitch, 6);

    //空滤报警指示灯
    //var $iconflag216 = $("#icon-flag2-16");
    //if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
    //    $iconflag216.removeClass('active');
    //} else {
    //}

    //电源总开关
    setLightStyle('#icon-flag25', lightFlag, 27);

    //车速
    var chart = $('#container-speed-2').highcharts(),
        point = chart.series[0].points[0];

    var speedVal = data.speedOfAMotorVehicle || 0;
    point.update(speedVal);
    $('#speed-text-2').empty().append(speedVal + '<span> <i>/</i> 限'+(data.limitSpeed || 55)+'</span>');

    //转速
    var rpmChart = $('#container-rpm-2').highcharts(),
        rmpPoint = rpmChart.series[0].points[0];
    var rpmVal = (data.rotateSpeed || 0) / 100;
    rmpPoint.update(rpmVal);
    $('#rpm-text-2').text((rpmVal * 100).toFixed(0));

    //动力电池电压
    var bvcChart = $('#battery-voltage-chart-2').highcharts(),
        bvcPoint = bvcChart.series[0].points[0];

    var bvcVal = Number((data.totalVoltage || 0).toFixed(1));
    if (bvcVal < 0) {
        bvcVal = 0;
    } else if (bvcVal > 800) {
        bvcVal = 800;
    }
    bvcPoint.update(bvcVal);
    $('#bvc-text-2').text(bvcVal);

    //动力电池电流
    var bccChart = $('#battery-circuit-chart-2').highcharts(),
        bccPoint = bccChart.series[0].points[0];

    var bccVal = Number((data.totalElectricCurrent || 0).toFixed(1));
    bccPoint.update(bccVal);
    $('#bcc-text-2').text(bccVal);

    //前气压
    var frontAirPressure = Number(((data.frontAirPressure || 0)).toFixed(1));
    var frontAirChart = $('#frontAirPressureChart-2').highcharts(),
        frontAirPoint = frontAirChart.series[0].points[0];
    frontAirPoint.update(frontAirPressure);
    $('#frontAir-p-2').text(frontAirPressure);

    //后气压
    var backAirPressure = Number(((data.backAirPressure || 0)).toFixed(1));
    var backAirChart = $('#backAirPressureChart-2').highcharts(),
        backAirPoint = backAirChart.series[0].points[0];
    backAirPoint.update(backAirPressure);
    $('#backAir-p-2').text(backAirPressure);

    //电池电压图表
    var batteryVoltage = Number((data.batteryElectricQuantity || 0).toFixed(1));
    $('#battery-voltage-text-2').empty().append(batteryVoltage + '<span>v</span>');
    $('#battery-voltage-2').animate({height: (batteryVoltage * 100 / 30) + '%'}, 800, 'easeOutBounce');

    //SOC图表
    var soc = Number(data.soc || 0).toFixed(1);
    if (soc < 0) {
        soc = 0;
    }
    if (soc > 100) {
        soc = 100;
    }
    $('#soc-text-2').empty().append(soc + '<span>%</span>');
    $('#soc-2').animate({height: soc + '%'}, 800, 'easeOutBounce');

    var $state = $('#state-2');
    if (lightFlag.charAt(21) == 1) {
        $state.text('READY');
    } else if (lightFlag.charAt(22) == 1) {
        $state.text('RUNNING');
    }
    //档位gearsStatus
    var gear = data.gearsStatus || 0;
    if (gear == 0) {
        $('#gear-2').text('N档');
        $('#gear-2').removeClass("red");
    } else if (gear == -1) {
        $('#gear-2').text('R档');
        $('#gear-2').addClass("red");
    } else if (gear == 1) {
        $('#gear-2').text('D档');
        $('#gear-2').removeClass("red");
    }


    //小计里程
    var subTotalMileage = Number((data.subtotalMile || 0).toFixed(2));
    $('#subTotalMileage-2').empty().append(subTotalMileage + ' <i>km</i>');

    //总里程
    var totalMileage = Number((data.totalMile || 0).toFixed(2));
    $('#totalMileage-2').empty().append(totalMileage + ' <i>km</i>');


    // 单体最高电压电池
    $('#single-high-voltage').text((data.highestVoltageBoxNO || 0) + '(箱)/' + (data.highestVoltageInboxLocation || 0) + '(个)/' + (data.highestBatteryVoltage || 0).toFixed(2) + '(V)');
    //单体最低电压电池
    $('#single-low-voltage').text((data.lowestVoltageBoxNO || 0) + '(箱)/' + (data.lowestVoltageInboxLocation || 0) + '(个)/' + (data.lowestBatteryVoltage || 0).toFixed(2) + '(V)');
    //单体最高温度电池
    $('#single-high-temp').text((data.highestTemperatureBoxNO || 0) + '(箱)/' + (data.hightestTemperatureInboxLocation || 0) + '(个)/' + (data.highestTemperature || 0) + '(℃)');
    //单体最低温度电池
    $('#single-low-temp').text((data.lowestTemperatureBoxNO || 0) + '(箱)/' + (data.lowestTemperatureInboxLocation || 0) + '(个)/' + (data.lowestTemperature || 0) + '(℃)');
}

//加载混合动力数据
function loadMixinEngineDataView(data) {
    //指示灯、报警灯
    var lightFlag = data.traditionalIndicatorLightSwitch || '';
    var lightFlagLength = lightFlag.length;
    var newEnergyIndicatorLightSwitch = data.newEnergyIndicatorLightSwitch || '';
    var newEnergyIndicatorLightSwitchLength = newEnergyIndicatorLightSwitch.length;
    //右转向灯
    setLightStyle($(".icon-flag9", $mixinEnergeContainer), lightFlag, 2);

    //左转向灯
    setLightStyle($(".icon-flag1", $mixinEnergeContainer), lightFlag, 1);

    // 后雾灯
    setLightStyle($(".icon-flag3", $mixinEnergeContainer), lightFlag, 6);

    // 前雾灯
    setLightStyle($(".icon-flag2", $mixinEnergeContainer), lightFlag, 5);

    //近光灯
    setLightStyle($(".icon-flag4", $mixinEnergeContainer), lightFlag, 4);

    //远光灯
    setLightStyle($(".icon-flag5", $mixinEnergeContainer), lightFlag, 3);

    //ABS
    setLightStyle($(".icon-flag6", $mixinEnergeContainer), lightFlag, 28);

    //驻车制动器
    setLightStyle($(".icon-flag7", $mixinEnergeContainer), lightFlag, 7);

    //脚刹指示灯
    setLightStyle($(".icon-flag10", $mixinEnergeContainer), lightFlag, 11);

    //电池统电指示灯
    setLightStyle($(".icon-flag15", $mixinEnergeContainer), newEnergyIndicatorLightSwitch, 5);

    //安全带指示灯
    setLightStyle('#icon-flag11', lightFlag, 30);
    // var $iconflag11 = $(".icon-flag11", $mixinEnergeContainer);
    // if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
    //     $iconflag11.removeClass('active');
    // } else {
    //     // $iconflag11.addClass('active');
    // }
    //Gps信号
    setGpsSignalStyle('.gps-icon1',lightFlag,30);

    //后仓门开信号
    setLightStyle($(".icon-flag16", $mixinEnergeContainer), lightFlag, 14);

    //位置灯指示
    setLightStyle($(".icon-flag17", $mixinEnergeContainer), lightFlag, 8);

    //前车门
    setLightStyle($(".icon-flag18", $mixinEnergeContainer), lightFlag, 12);

    //中门
    setLightStyle($(".icon-flag19", $mixinEnergeContainer), lightFlag, 13);

    //严重故障
    setLightStyle($(".icon-flag2-1", $mixinEnergeContainer), lightFlag, 10);

    //蓄电池指示灯
    var $iconflag22 = $(".icon-flag2-2", $mixinEnergeContainer);
    if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
        $iconflag22.removeClass('active');
    } else {
        // $iconflag22.addClass('active');
    }
    //充电连接故障
    var $iconflag23 = $(".icon-flag2-3", $mixinEnergeContainer);
    if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
        $iconflag23.removeClass('active');
    } else {
        //$iconflag23.addClass('active');
    }
    //胎压报警
    setLightStyle($(".icon-flag2-4", $mixinEnergeContainer), lightFlag, 24);

    //电机及按制器过热
    setLightStyle($(".icon-flag2-5", $mixinEnergeContainer), newEnergyIndicatorLightSwitch, 8);

    //电机超速报警
    var $iconflag26 = $(".icon-flag2-6", $mixinEnergeContainer);
    if (!newEnergyIndicatorLightSwitch || newEnergyIndicatorLightSwitch.charAt(lightFlagLength - 1) % 2 === 0) {
        $iconflag26.removeClass('active');
    } else {
        // $iconflag26.addClass('active');
    }
    //整车控制器故障
    var $iconflag27 = $(".icon-flag2-7", $mixinEnergeContainer);
    if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
        $iconflag27.removeClass('active');
    } else {
        //   $iconflag27.addClass('active');
    }
    //下车铃指示灯
    setLightStyle($(".icon-flag2-8", $mixinEnergeContainer), lightFlag, 18);

    //干燥器
    var $iconflag29 = $(".icon-flag2-9", $mixinEnergeContainer);
    if (!newEnergyIndicatorLightSwitchLength || newEnergyIndicatorLightSwitch.charAt(newEnergyIndicatorLightSwitchLength - 1) % 2 === 0) {
        $iconflag29.removeClass('active');
    } else if (newEnergyIndicatorLightSwitch.charAt(newEnergyIndicatorLightSwitchLength - 1) == 3) {
        $iconflag29.removeClass('active');
    } else {
        $iconflag29.addClass('active');
    }
    //左蹄片报警
    setLightStyle($(".icon-flag2-10", $mixinEnergeContainer), lightFlag, 19);

    //右蹄片报警
    setLightStyle($(".icon-flag2-11", $mixinEnergeContainer), lightFlag, 20);

    //ASR故障
    setLightStyle($(".icon-flag2-12", $mixinEnergeContainer), lightFlag, 29);

    //制动器故障
    var $iconflag213 = $(".icon-flag2-13", $mixinEnergeContainer);
    if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 29) % 2 === 0) {
        $iconflag213.removeClass('active');
    } else {
        //   $iconflag213.addClass('active');
    }
    //动力电池故障
    setLightStyle($(".icon-flag2-14", $mixinEnergeContainer), newEnergyIndicatorLightSwitch, 4);

    //系统故障
    setLightStyle($(".icon-flag2-15", $mixinEnergeContainer), newEnergyIndicatorLightSwitch, 6);

    //空滤报警指示灯
    //var $iconflag216 = $(".icon-flag2-16",$mixinEnergeContainer);
    //if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
    //    $iconflag216.removeClass('active');
    //}


    //车速
    var chart = $('#container-speed-3').highcharts(),
        point = chart.series[0].points[0];

    var speedVal = data.speedOfAMotorVehicle || 0;
    point.update(speedVal);
    $('#speed-text-3').empty().append(speedVal + '<span> <i>/</i> 限'+(data.limitSpeed || 55)+'</span>');

    //转速
    var rpmChart = $('#container-rpm-3').highcharts(),
        rmpPoint = rpmChart.series[0].points[0];
    var rpmVal = (data.rotateSpeed / 100) || 0;
    rmpPoint.update(rpmVal);
    $('#rpm-text-3').text((rpmVal * 100).toFixed(0));

    //动力电池电压
    var bvcChart = $('#battery-voltage-chart-3').highcharts(),
        bvcPoint = bvcChart.series[0].points[0];

    var bvcVal = Number((data.totalVoltage || 0).toFixed(1));
    if (bvcVal < 0) {
        bvcVal = 0;
    } else if (bvcVal > 800) {
        bvcVal = 800;
    }
    bvcPoint.update(bvcVal);
    $('#bvc-text-3').text(bvcVal);

    //动力电池电流
    var bccChart = $('#battery-circuit-chart-3').highcharts(),
        bccPoint = bccChart.series[0].points[0];

    var bccVal = Number((data.totalElectricCurrent || 0).toFixed(1));
    bccPoint.update(bccVal);
    $('#bcc-text-3').text(bccVal);

    //前气压
    var frontAirPressure = Number(((data.frontAirPressure || 0) ).toFixed(1));
    var frontAirChart = $('#frontAirPressureChart-3').highcharts(),
        frontAirPoint = frontAirChart.series[0].points[0];
    frontAirPoint.update(frontAirPressure);
    $('#frontAir-p-3').text(frontAirPressure);

    //后气压
    var backAirPressure = Number(((data.backAirPressure || 0) ).toFixed(1));
    var backAirChart = $('#backAirPressureChart-3').highcharts(),
        backAirPoint = backAirChart.series[0].points[0];
    backAirPoint.update(backAirPressure);
    $('#backAir-p-3').text(backAirPressure);

    //电池电压图表
    var batteryVoltage = Number((data.batteryElectricQuantity || 0).toFixed(1));
    $('#battery-voltage-text-3').empty().append(batteryVoltage + '<span>v</span>');
    $('#battery-voltage-3').animate({height: (batteryVoltage * 100 / 30) + '%'}, 800, 'easeOutBounce');


    //水温
    var $waterTemp = $('#water-temp-3'),
        waterTemp = data.waterTemperature || 0;
    $('.num-area', $waterTemp).animate({height: waterTemp > 100 ? '100' : waterTemp + '%'}, 800, 'easeOutBounce');
    $('p', $waterTemp).empty().append(waterTemp + '<span>℃</span>');

    //机油压力
    var engineOilPressure = ((data.engineOilPressure || 0)).toFixed(2),
        $engineOilPressure = $('#engineOilPressure-3');
    $('.num-area', $engineOilPressure).animate({height: (engineOilPressure * 100) + '%'}, 800, 'easeOutBounce');
    $('p', $engineOilPressure).empty().append(engineOilPressure + '<span>mpa</span>');

    //SOC图表
    var soc = Number(data.soc || 0).toFixed(1);
    if (soc < 0) {
        soc = 0;
    }
    if (soc > 100) {
        soc = 100;
    }
    $('#soc-text-3').empty().append(soc + '<span>%</span>');
    $('#soc-3').animate({height: soc + '%'}, 800, 'easeOutBounce');

    var $state = $('#state-3');
    if (lightFlag.charAt(21) == 1) {
        $state.text('READY');
    } else if (lightFlag.charAt(22) == 1) {
        $state.text('RUNNING');
    }
    //档位gearsStatus
    var gear = data.gearsStatus || 0;
    if (data.carType == 3) {
        $('#gear-3').text(data.gearsStatus + '档');
    } else {
        if (gear == 0) {
            $('#gear-3').text('N档');
            $('#gear-2').removeClass("red");
        } else if (gear == -1) {
            $('#gear-3').text('R档');
            $('#gear-2').addClass("red");

        } else if (gear == 1) {
            $('#gear-3').text('D档');
            $('#gear-2').removeClass("red");
        } else if (gear == 15) {
            $('#gear-3').text('L档');
            $('#gear-2').removeClass("red");
        }
    }

    //瞬时能耗
    var instantFuelConsumption = Number((data.instantFuelConsumption || 0).toFixed(2));
    $('#instEnergy-3').empty().append(instantFuelConsumption + ' <span>L/H</span>');

    //尿素
    var ureaLevel = Number((data.ureaLevel || 0).toFixed(2));
    $('#carbamide-3').empty().append(ureaLevel + ' <span>%</span>');

    //总能耗
    var totalFuelConsumption = Number((data.totalFuelConsumption || 0).toFixed(2));
    $('#totalEnergy-3').empty().append(totalFuelConsumption + ' <i>L</i>');
    //==

    //小计里程
    var subTotalMileage = Number((data.subtotalMile || 0).toFixed(2));
    $('#subTotalMileage-3').empty().append(subTotalMileage + ' <i>km</i>');

    //总里程
    var totalMileage = Number((data.totalMile || 0).toFixed(2));
    $('#totalMileage-3').empty().append(totalMileage + ' <i>km</i>');

    //油量
    $('#mixin-oil').find('.p1').text((data.oilMass || 0) + '%').end().find('.num-area').css({width: (data.oilMass || 0) + '%'});

    var stmSt = data.stmSt || '0';
    //整车控制系统
    var stmStByte56 = stmSt.substr(stmSt.length - 3, 1);
    switch (stmStByte56) {
        case '0':
            $('#whole-car-text').text('正常');
            break;
        case '1':
            $('#whole-car-text').text('限功');
            break;
        case '2':
            $('#whole-car-text').text('跛行');
            break;
        case '3':
            $('#whole-car-text').text('紧急');
            break;
        default :
            $('#whole-car-text').text('');
            break;
    }

    //发动机
    var stmStByte34 = stmSt.substr(stmSt.length - 2, 1);
    switch (stmStByte34) {
        case '0':
            $('#engine-text').text('待机').removeClass('color-f25151');
            break;
        case '1':
            $('#engine-text').text('驱动').removeClass('color-f25151');
            break;
        case '2':
            $('#engine-text').text('发电').removeClass('color-f25151');
            break;
        case '3':
            $('#engine-text').text('故障').addClass('color-f25151');
            break;
        default :
            $('#engine-text').text('').removeClass('color-f25151');
            break;
    }

    //电机
    var stmStByte12 = stmSt.substr(stmSt.length - 1, 1);
    switch (stmStByte12) {
        case '0':
            $('#electrical-text').text('待机').removeClass('color-f25151');
            break;
        case '1':
            $('#electrical-text').text('驱动').removeClass('color-f25151');
            break;
        case '2':
            $('#electrical-text').text('发电').removeClass('color-f25151');
            break;
        case '3':
            $('#electrical-text').text('故障').addClass('color-f25151');
            break;
        default :
            $('#electrical-text').text('').removeClass('color-f25151');
            break;
    }
    //电机转速
    var electricMachineryRotateSpeed = Number((data.electricMachineryRotateSpeed || 0).toFixed(2));
    $('#electricMachineryRotateSpeed').empty().append(electricMachineryRotateSpeed);

    var hybridLightSwitch = data.hybridLightSwitch || '';
    //钥匙档位
    var $iconFlag20 = $('.icon-flag20', $mixinEnergeContainer);
    $iconFlag20.removeClass('active active-acc');

    if (hybridLightSwitch && hybridLightSwitch.charAt(hybridLightSwitch.length - 2) % 2 == 1) {
        $iconFlag20.addClass('active');
    }
    if (hybridLightSwitch && hybridLightSwitch.charAt(hybridLightSwitch.length - 1) % 2 == 1) {
        $iconFlag20.addClass('active-acc');
    }

    //发动机预热
    setLightStyle('#icon-flag21', hybridLightSwitch, 3);

    //左侧气囊气压
    $('#left-gas-bag').find('p:eq(0)').text((data.leftAirbagsAirPrs || 0) + 'MPA').end().find('.num-area').css({height: ((data.leftAirbagsAirPrs || 0) * 100) + '%'});

    //右侧气囊气压
    $('#right-gas-bag').find('p:eq(0)').text((data.rightAirbagsAirPrs || 0) + 'MPA').end().find('.num-area').css({height: ((data.rightAirbagsAirPrs || 0) * 100) + '%'});

    //制动踏板
    $('#brake-pedal').find('.p1').text((data.brakPedalPetg || 0) + '%').end().find('.num-area').css({width: (data.brakPedalPetg || 0) + '%'});

    //牵引踏板
    $('#pull-pedal').find('.p1').text((data.tractionPedalPetg || 0) + '%').end().find('.num-area').css({width: (data.tractionPedalPetg || 0) + '%'});

    var swtcNumSt = data.swtcNumSt || '0';
    //发动机启动
    setLightStyle($('.icon-flag22', $mixinEnergeContainer), swtcNumSt, 7);

    //AC空调信号
    setLightStyle($('.icon-flag23', $mixinEnergeContainer), swtcNumSt, 5);

    //接触器信号
    var $contactorSignal = $('#contactor-signal');
    //电容主接触器
    setLightStyle($('div:eq(0)', $contactorSignal), swtcNumSt, 1);
    //电容预充电接触器
    setLightStyle($('div:eq(1)', $contactorSignal), swtcNumSt, 2);
    //电池主接触器
    setLightStyle($('div:eq(2)', $contactorSignal), swtcNumSt, 3);
    //电池预充电接触器
    setLightStyle($('div:eq(3)', $contactorSignal), swtcNumSt, 4);
    //电制动
    setLightStyle($('div:eq(4)', $contactorSignal), swtcNumSt, 8);
}

//加载双路BMS数据
function loadBMSDataView(data) {
    var lightFlag = data.traditionalIndicatorLightSwitch || '';
    var lightFlagLength = lightFlag.length;
    var newEnergyIndicatorLightSwitch = data.newEnergyIndicatorLightSwitch || '';
    //右转向灯
    setLightStyle($('.icon-flag9', $bmsContainer), lightFlag, 2);
    //左转向灯
    setLightStyle($('.icon-flag1', $bmsContainer), lightFlag, 1);
    // 后雾灯
    setLightStyle($('.icon-flag3', $bmsContainer), lightFlag, 6);
    // 前雾灯
    setLightStyle($('.icon-flag2', $bmsContainer), lightFlag, 5);
    //近光灯
    setLightStyle($('.icon-flag4', $bmsContainer), lightFlag, 4);
    //远光灯
    setLightStyle($('.icon-flag5', $bmsContainer), lightFlag, 3);
    //ABS
    setLightStyle($('.icon-flag6', $bmsContainer), lightFlag, 28);
    //驻车制动器
    setLightStyle($('.icon-flag7', $bmsContainer), lightFlag, 7);
    //脚刹指示灯
    setLightStyle($('.icon-flag10', $bmsContainer), lightFlag, 11);
    //电池统电指示灯
    setLightStyle($('.icon-flag15', $bmsContainer), newEnergyIndicatorLightSwitch, 5);
    //安全带指示灯
    setLightStyle('#icon-flag11', lightFlag, 30);
    // var $iconflag11 = $(".icon-flag11", $bmsContainer);
    // if (!lightFlagLength || lightFlag.charAt(lightFlagLength - 1) % 2 === 0) {
    //     $iconflag11.removeClass('active');
    // } else {
    // }
    //Gps信号
    setGpsSignalStyle('.gps-icon1',lightFlag,30);

    //后仓门开信号
    setLightStyle($('.icon-flag16', $bmsContainer), lightFlag, 14);
    //位置灯指示
    setLightStyle($('.icon-flag17', $bmsContainer), lightFlag, 8);
    //前车门
    setLightStyle($('.icon-flag18', $bmsContainer), lightFlag, 12);
    //中门
    setLightStyle($('.icon-flag19', $bmsContainer), lightFlag, 13);


    //车速
    var chart = $('.speed-meter', $bmsContainer).highcharts(),
        point = chart.series[0].points[0];

    var speedVal = data.speedOfAMotorVehicle || 0;
    point.update(speedVal);
    $('.speed-text', $bmsContainer).empty().append(speedVal + '<span> <i>/</i> 限'+(data.limitSpeed || 55)+'</span>');

    //转速
    var rpmChart = $('.rpm-meter', $bmsContainer).highcharts(),
        rmpPoint = rpmChart.series[0].points[0];
    var rpmVal = (data.rotateSpeed || 0) / 100;
    rmpPoint.update(rpmVal);
    $('.rpm-text', $bmsContainer).text((rpmVal * 100).toFixed(0));


    var $state = $('.ready', $bmsContainer);
    if (lightFlag.charAt(21) == 1) {
        $state.text('READY');
    } else if (lightFlag.charAt(22) == 1) {
        $state.text('RUNNING');
    }
    //档位gearsStatus
    var gear = data.gearsStatus || 0;
    var $gear = $('.degree', $bmsContainer);
    if (gear == 0) {
        $gear.text('N档');
    } else if (gear == -1) {
        $gear.text('R档');
    } else if (gear == 1) {
        $gear.text('D档');
    }

    //小计里程
    var subTotalMileage = Number((data.subtotalMile || 0).toFixed(2));
    $('#subTotalMileage-4').empty().append(subTotalMileage + ' <i>km</i>');

    //总里程
    var totalMileage = Number((data.totalMile || 0).toFixed(2));
    $('#totalMileage-4').empty().append(totalMileage + ' <i>km</i>');

    //前气压
    var frontAirPressure = parseFloat(((data.frontAirPressure || 0) ).toFixed(2));
    $('.front-gasbag .num-area', $bmsContainer).css({height: frontAirPressure * 100 + '%'});
    $('.front-gasbag>p:first', $bmsContainer).text(frontAirPressure + 'MPA');
    //后气压
    var backAirPressure = parseFloat(((data.backAirPressure || 0) ).toFixed(2));
    $('.black-gasbag .num-area', $bmsContainer).css({height: backAirPressure * 100 + '%'});
    $('.black-gasbag>p:first', $bmsContainer).text(backAirPressure + 'MPA');

    //动力电池电压1、2
    var bvcVal = Number((data.totalVoltage || 0).toFixed(1));
    if (bvcVal < 0) {
        bvcVal = 0;
    } else if (bvcVal > 800) {
        bvcVal = 800;
    }
    updateMeterValue($('.battery-voltage-meter1', $bmsContainer), bvcVal);
    $('.dldcdy1', $bmsContainer).text(bvcVal);

    var bvcVal2 = Number((data.totalVoltage1 || 0).toFixed(1));
    if (bvcVal2 < 0) {
        bvcVal2 = 0;
    } else if (bvcVal2 > 800) {
        bvcVal2 = 800;
    }
    updateMeterValue($('.battery-voltage-meter2', $bmsContainer), bvcVal2);
    $('.dldcdy2', $bmsContainer).text(bvcVal2);
    //动力电池电流1、2
    var bccVal = Number((data.totalElectricCurrent || 0).toFixed(1));
    updateMeterValue($('.battery-circuit-meter1', $bmsContainer), bccVal);
    $('.dldcdl1', $bmsContainer).text(bccVal);

    var bccVal2 = Number((data.totalElectricCurrent1 || 0).toFixed(1));
    updateMeterValue($('.battery-circuit-meter2', $bmsContainer), bccVal2);
    $('.dldcdl2', $bmsContainer).text(bccVal2);

    //soc1、2
    var soc = Number(data.soc || 0).toFixed(1);
    if (soc < 0) {
        soc = 0;
    }
    if (soc > 100) {
        soc = 100;
    }
    var $soc1 = $('.soc1', $bmsContainer);
    $('.num-area', $soc1).css({height: soc + '%'});
    $('>p', $soc1).html(soc + '<span>%</span>');

    var soc2 = Number(data.soc1 || 0).toFixed(1);
    if (soc2 < 0) {
        soc2 = 0;
    }
    if (soc2 > 100) {
        soc2 = 100;
    }
    var $soc2 = $('.soc2', $bmsContainer);
    $('.num-area', $soc2).css({height: soc2 + '%'});
    $('>p', $soc2).html(soc2 + '<span>%</span>');

    //蓄电池电压
    var batteryVoltage = Number((data.batteryElectricQuantity || 0).toFixed(1));
    $('.totalDY .num-area', $bmsContainer).css({width: (batteryVoltage * 100 / 30) + '%'});
    $('.totalDY p', $bmsContainer).text(batteryVoltage + 'v');

    // 单体最高电压电池
    $('#single-high-voltage').text((data.highestVoltageBoxNO || 0) + '(箱)/' + (data.highestVoltageInboxLocation || 0) + '(个)/' + (data.highestBatteryVoltage || 0).toFixed(2) + '(V)');
    //单体最低电压电池
    $('#single-low-voltage').text((data.lowestVoltageBoxNO || 0) + '(箱)/' + (data.lowestVoltageInboxLocation || 0) + '(个)/' + (data.lowestBatteryVoltage || 0).toFixed(2) + '(V)');
    //单体最高温度电池
    $('#single-high-temp').text((data.highestTemperatureBoxNO || 0) + '(箱)/' + (data.hightestTemperatureInboxLocation || 0) + '(个)/' + (data.highestTemperature || 0) + '(℃)');
    //单体最低温度电池
    $('#single-low-temp').text((data.lowestTemperatureBoxNO || 0) + '(箱)/' + (data.lowestTemperatureInboxLocation || 0) + '(个)/' + (data.lowestTemperature || 0) + '(℃)');
    //电池箱体状态1、2
    var _battery1Html = '<div class="fl">' +
        '           <p title="单体最高电池电压">' + (data.highestVoltageBoxNO || 0) + '(箱)/' + (data.highestVoltageInboxLocation || 0) + '(个)/' + (data.highestBatteryVoltage || 0).toFixed(2) + '(V)</p>' +
        '           <p title="单体最低电池电压">' + (data.lowestVoltageBoxNO || 0) + '(箱)/' + (data.lowestVoltageInboxLocation || 0) + '(个)/' + (data.lowestBatteryVoltage || 0).toFixed(2) + '(V)</p>' +
        '      </div>' +
        '      <div class="fr">' +
        '           <p title="单体最高电池温度">' + (data.highestTemperatureBoxNO || 0) + '(箱)/' + (data.hightestTemperatureInboxLocation || 0) + '(个)/' + (data.highestTemperature || 0) + '(℃)</p>' +
        '           <p title="单体最高电池温度">' + (data.lowestTemperatureBoxNO || 0) + '(箱)/' + (data.lowestTemperatureInboxLocation || 0) + '(个)/' + (data.lowestTemperature || 0) + '(℃)</p>' +
        '      </div>';
    $('.battery1', $bmsContainer).empty().append(_battery1Html);
    var _battery2Html = '<div class="fl">' +
        '           <p title="单体最高电池电压">' + (data.highestVoltageBoxNO1 || 0) + '(箱)/' + (data.highestVoltageInboxLocation1 || 0) + '(个)/' + (data.highestBatteryVoltage1 || 0).toFixed(2) + '(V)</p>' +
        '           <p title="单体最低电池电压">' + (data.lowestVoltageBoxNO1 || 0) + '(箱)/' + (data.lowestVoltageInboxLocation1 || 0) + '(个)/' + (data.lowestBatteryVoltage1 || 0).toFixed(2) + '(V)</p>' +
        '      </div>' +
        '      <div class="fr">' +
        '           <p title="单体最高电池温度">' + (data.highestTemperatureBoxNO1 || 0) + '(箱)/' + (data.hightestTemperatureInboxLocation1 || 0) + '(个)/' + (data.highestTemperature1 || 0) + '(℃)</p>' +
        '           <p title="单体最高电池温度">' + (data.lowestTemperatureBoxNO1 || 0) + '(箱)/' + (data.lowestTemperatureInboxLocation1 || 0) + '(个)/' + (data.lowestTemperature1 || 0) + '(℃)</p>' +
        '      </div>';
    $('.battery2', $bmsContainer).empty().append(_battery2Html);
}

require(['monitor', 'jquery-ui', 'gaodeMap', 'highcharts', 'gauge'], function () {

    bindEvents();
    traditionConInit();

    map = new MapGaoDe(107.49023438, 36.24427318, 2);
    $monitor.monitor({
        canId: '07',
        callback: function (data) {
            loadData(data || {});
        },
        clearData: function () {
            loadData({});
        }
    });

    /**
     * 切换仪表盘显示、线路文字显示等
     * @param event
     * @param treeId
     * @param treeNode
     */
    function carChange(event, treeId, treeNode) {

        if (treeNode.type !== "CAR") {
            return;
        }

        //当监控正在进行时，点击左侧树的其它车辆就取消选择点击的车辆，选中正在监控的车辆对应的节点
        if ($monitor.monitor('getStatus') == 'monitor') {
            var treeObj = window.parent.$.fn.zTree.getZTreeObj(treeId);
            treeObj.cancelSelectedNode(treeNode);
            var node = treeObj.getNodeByParam('id', selectCarId);
            if (node) {
                treeObj.selectNode(node);
            }
            return;
        }


        var treeObj = window.parent.$.fn.zTree.getZTreeObj(treeId);
        var parentNode = treeObj.getNodeByTId(treeNode.parentTId);
        var parentName = parentNode.name;
        currentCarId = treeNode.id;
        meterSwitch(treeNode.typeDetail);
        if (treeNode.lockCarSt != undefined) {
            setCarLockLabelAndStyle(treeNode.lockCarSt);
        }
        if (currentCarType == 1) {
            if (treeNode.flOilType == 'FUT00005') {
                $('#oilnum-name').text('气量');
            } else {
                $('#oilnum-name').text('油量');
            }
        }
        $('#line-info').text(parentName.replace(/\[\S+\]/, '') + " " + treeNode.name);
        console.info( treeNode.id);
        $.ajaxExt({
			url: '/baseCarInfo/getDrvName.htm',
			data: {'carId': treeNode.id},
			success: function (data) {
				$('#line-info').text(parentName.replace(/\[\S+\]/, '') + " " + treeNode.name+ " " +data);
			}
		});
        
    }

    //左侧树单击事件
    commonFun.leftTreeNodeClickObj['carChange'] = carChange;

    //当左侧树要选择车辆时自动切换车辆类型仪表
    business.execFnByLeftTreeSelectNode('CAR', carChange);

    checkSelCar = function(data){
        commonFun.setSelectedNodes(data.carId);
        // $("a[class='btn btn-overlay']").click();
    };

});
